//
//  helpCoverView.m
//  shanHaiHuiApp
//
//  Created by DS on 2018/9/28.
//  Copyright © 2018年 徐双. All rights reserved.
//

#import "helpCoverView.h"

@interface helpCoverView()


//帮助的弹窗

Strong UIImageView * helpImageView;
Strong UILabel * helpLabel1;
Strong UILabel * helpLabel2;
Strong UILabel * helpLabel3;
Strong UILabel * helpLabel4;

@end


@implementation helpCoverView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.alpha = 0;
        UIButton *backButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
        backButton.backgroundColor = [UIColor whiteColor];
        backButton.alpha = 0;
        backButton.titleLabel.font = DEF_FontSize_13;
        [backButton addTarget:self action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:backButton];
        [self addSubview:self.helpImageView];
        
        
    }
    return self;
}


- (UIImageView *)helpImageView{
   
    
    if (!_helpImageView) {
        
        
        _helpImageView = [[UIImageView alloc] init];
        _helpImageView.image = [UIImage imageNamed:@"yaoshidianping-spdy"];
        
        _helpImageView.frame = CGRectMake(UNIT_WIDTH(10), UNIT_HEIGHT(10), UNIT_WIDTH(350), UNIT_HEIGHT(150));
        
        
        _helpLabel1 = [[UILabel alloc] init];
        _helpLabel1.font = DEF_FontSize_11;
        _helpLabel1.textColor = getColor(@"666666");
        _helpLabel1.text = @"会员自提：在出货超市现场购买，即买即提";

        _helpLabel2 = [[UILabel alloc] init];
        _helpLabel2.font = DEF_FontSize_11;
        _helpLabel2.textColor = getColor(@"666666");
        _helpLabel2.text = @"会员配送：预先下单，由出货超市配送到会员指定的地址";
        
        _helpLabel3 = [[UILabel alloc] init];
        _helpLabel3.font = DEF_FontSize_11;
        _helpLabel3.textColor = getColor(@"666666");
        _helpLabel3.text = @"门店配送：预先下单，由出货超市配送到销售门店";

        _helpLabel4 = [[UILabel alloc] init];
        _helpLabel4.font = DEF_FontSize_11;
        _helpLabel4.textColor = getColor(@"666666");
        _helpLabel4.text = @"门店自提：预先下单，销售门店到出货超市自提";
        
        [_helpImageView sd_addSubviews:@[self.helpLabel1,self.helpLabel2,self.helpLabel3,self.helpLabel4]];
        
        
        
//        [_helpImageView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.mas_equalTo(UNIT_HEIGHT(100));
//            make.right.mas_equalTo(UNIT_WIDTH(-10));
//            make.left.mas_equalTo(UNIT_WIDTH(66));
//            make.height.mas_equalTo(UNIT_HEIGHT(100));
//        }];
        
        [self.helpLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.top.mas_equalTo(UNIT_HEIGHT(5));
            make.left.mas_equalTo(UNIT_WIDTH(10));
            make.height.mas_equalTo(UNIT_HEIGHT(30));
        
        }];
        
        [self.helpLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.top.mas_equalTo(self.helpLabel1.mas_bottom).offset(UNIT_HEIGHT(5));
            make.left.mas_equalTo(UNIT_WIDTH(10));
            make.height.mas_equalTo(UNIT_HEIGHT(30));
            
        }];
        
        [self.helpLabel3 mas_makeConstraints:^(MASConstraintMaker *make) {
            
             make.top.mas_equalTo(self.helpLabel2.mas_bottom).offset(UNIT_HEIGHT(5));
            make.left.mas_equalTo(UNIT_WIDTH(10));
            make.height.mas_equalTo(UNIT_HEIGHT(30));
            
        }];
        
        [self.helpLabel4 mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.top.mas_equalTo(self.helpLabel3.mas_bottom).offset(UNIT_HEIGHT(5));
            make.left.mas_equalTo(UNIT_WIDTH(10));
            make.height.mas_equalTo(UNIT_HEIGHT(30));
            
        }];
        
        
    }
    
    return _helpImageView;
}



#pragma mark -- 显示还是不显示
//出现
-(void)show{
    [[UIApplication sharedApplication].delegate.window addSubview:self];
    [UIView animateWithDuration:.15 animations:^{
        self.alpha = 1;
    }];
}

//消失
-(void)dismiss{
    [UIView animateWithDuration:.15 animations:^{
        self.alpha = 0 ;
    } completion:^(BOOL finished) {
        [self removeFromSuperview];
    }];
}

@end
